import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import {
  RestockingPlanSumSupplierRelVO,
  RestockingPlanSumSupplierRelForm,
  RestockingPlanSumSupplierRelQuery
} from '@/api/plan/restockingPlanSumSupplierRel/types';
import { RestockingPlanSumVO } from '@/api/plan/restockingPlanSum/types';

/**
 * 查询下单计划汇总关联供应商列表
 * @param query
 * @returns {*}
 */

export const listRestockingPlanSumSupplierRel = (query?: RestockingPlanSumSupplierRelQuery): AxiosPromise<RestockingPlanSumSupplierRelVO[]> => {
  return request({
    url: '/plan/restockingPlanSumSupplierRel/list',
    method: 'get',
    params: query
  });
};

/**
 * 查询下单计划汇总关联供应商详细
 * @param id
 */
export const getRestockingPlanSumSupplierRel = (id: string | number): AxiosPromise<RestockingPlanSumSupplierRelVO> => {
  return request({
    url: '/plan/restockingPlanSumSupplierRel/' + id,
    method: 'get'
  });
};

/**
 * 新增下单计划汇总关联供应商
 * @param data
 */
export const addRestockingPlanSumSupplierRel = (data: RestockingPlanSumSupplierRelForm) => {
  return request({
    url: '/plan/restockingPlanSumSupplierRel',
    method: 'post',
    data: data
  });
};

/**
 * 修改下单计划汇总关联供应商
 * @param data
 */
export const updateRestockingPlanSumSupplierRel = (data: RestockingPlanSumSupplierRelForm) => {
  return request({
    url: '/plan/restockingPlanSumSupplierRel',
    method: 'put',
    data: data
  });
};

/**
 * 删除下单计划汇总关联供应商
 * @param id
 */
export const delRestockingPlanSumSupplierRel = (id: string | number | Array<string | number>) => {
  return request({
    url: '/plan/restockingPlanSumSupplierRel/' + id,
    method: 'delete'
  });
};

export const getHistoryBindSupplier = (id: string | number): AxiosPromise<RestockingPlanSumVO> => {
  return request({
    url: '/plan/restockingPlanSum/getHistoryBindSupplier/' + id,
    method: 'get'
  });
};
